
package nccloud.impl.arap.txdj.action;

import nc.bs.ml.NCLangResOnserver;
import nc.bs.pub.action.N_TXDJ_UNAPPROVE;
import nc.impl.pubapp.pattern.data.bill.BillQuery;
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
import nc.vo.arap.amortization.AggAmortizationVO;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.pattern.log.TimeLog;
import nccloud.bs.arap.txdj.maintain.rule.audit.CheckEnableUnauditRule;
import nccloud.bs.arap.txdj.maintain.rule.unsave.UnSaveRule;
import nccloud.bs.arap.txdj.plugin.ActionPlugInPoint;

public class UnApproveAction {
        public AggAmortizationVO[] unApprove(N_TXDJ_UNAPPROVE script) {
                AggAmortizationVO[] ret = null;

                try {
                        Object[] inCurObject = script.getPfParameterVO().m_preValueVos;
                        if (inCurObject == null) {
                                ExceptionUtils.wrappBusinessException(
                                                NCLangResOnserver.getInstance().getStrByID("4009001_0", "04009001-0064"));
                                return null;
                        }

                        AggAmortizationVO[] inCurVOs = new AggAmortizationVO[inCurObject.length];
                        int len = inCurObject.length;

                        for (int i = 0; i < len; ++i) {
                                inCurVOs[i] = (AggAmortizationVO) inCurObject[i];
                        }

                        AroundProcesser<AggAmortizationVO> processer = new AroundProcesser(ActionPlugInPoint.UnApproveAction);
                        processer.addBeforeRule(new CheckEnableUnauditRule());
                        processer.addBeforeRule(new UnSaveRule());
                        TimeLog.logStart();
                        processer.before(inCurVOs);
                        TimeLog.info("调用审批流前执行业务规则");
                        script.procUnApproveFlow(script.getPfParameterVO());
                        TimeLog.logStart();
                        processer.after(inCurVOs);
                        TimeLog.info("调用审批流后执行业务规则");
                        ret = this.queryNewVO(inCurVOs);
                } catch (Exception var7) {
                        ExceptionUtils.wrappException(var7);
                }

                return ret;
        }

        private AggAmortizationVO[] queryNewVO(AggAmortizationVO[] inCurVOs) {
                int len = inCurVOs.length;
                String[] ids = new String[len];

                for (int i = 0; i < len; ++i) {
                        ids[i] = inCurVOs[i].getPrimaryKey();
                }

                BillQuery<AggAmortizationVO> query = new BillQuery(AggAmortizationVO.class);
                AggAmortizationVO[] bills = (AggAmortizationVO[]) query.query(ids);
                return bills;
        }
}
